package cn.tedu;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class Demo09 {
    //注册:用户名,密码,昵称(nickname)
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名:");
        String name = sc.nextLine();
        System.out.println("请输入密码:");
        String password = sc.nextLine();
        System.out.println("请输入昵称:");
        String nickname = sc.nextLine();
        //插入数据
        try(Connection conn = DBUtils.getConn()) {
            Statement s = conn.createStatement();
            s.executeUpdate("insert into user values(null,'"+name+"','"+password+"','"+nickname+"')");
            System.out.println("执行成功");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
